﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Error : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string errorType = null;
        string errorTitle = null;
        string errorContent = null;
        if (Request.QueryString["type"] != null)
        {
            errorType = Request.QueryString["type"];
            if (errorType == "custom")
            {
                if (Request.QueryString["title"] != null)
                {
                    messagetitle.InnerText = Request.QueryString["title"];
                }
                else
                    messagetitle.InnerText = "未知错误类型";
                if (Request.QueryString["content"] != null)
                {
                    messagecontent.InnerText = Request.QueryString["content"];
                }
                else
                    messagecontent.InnerText = "未知错误信息";
            }
            else if (errorType == "NeedLogin")
            {
                messagetitle.InnerText = "需要登录";
                messagecontent.InnerText = "请登录后重试操作";
            }
            else if (errorType == "LoginFailed")
            {
                messagetitle.InnerText = "登陆失败";
                messagecontent.InnerText = "请检查用户名密码";
            }
            else if (errorType == "WrongPassword")
            {
                messagetitle.InnerText = "登陆失败";
                messagecontent.InnerText = "密码不正确";
            }
            else if (errorType == "UserNoExsit")
            {
                messagetitle.InnerText = "登陆失败";
                messagecontent.InnerText = "用户名不存在";
            }
            else if (errorType == "ParamWrong")
            {
                messagetitle.InnerText = "参数错误";
                messagecontent.InnerText = "缺少参数或者参数格式不正确";
            }else if (errorType == "ConnectToDBWrong")
            {
                messagetitle.InnerText = "连接到数据库失败";
                messagecontent.InnerText = "如果情况一直出现，请联系管理员";
            }

            else
            {
                messagetitle.InnerText = "错误类型未定义";
                messagecontent.InnerText = "没有这种错误呀，所以也没有详细提示丫";
            }
        }
        else
        {
            messagetitle.InnerText = "未知错误类型";
            messagecontent.InnerText = "未知错误信息";
        }

        if (Request.QueryString["back"] == "yes" )
        {
            string text = "<meta http-equiv=\"refresh\" content=\"3;url="
                        + Request.UrlReferrer + "\">";
            Literal_meta.Text = text;
        }
        if (Request.QueryString["goto"] != null)
        {
            string text = "<meta http-equiv=\"refresh\" content=\"3;url="
                        + Request.QueryString["goto"] + "\">";
            Literal_meta.Text = text;
        }
    }
}